﻿<UserControl x:Class="DeltaGroup.WheelOfJeopardy.UI.Screens.GamePanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Screens="clr-namespace:DeltaGroup.WheelOfJeopardy.UI.Screens" xmlns:Commands="clr-namespace:DeltaGroup.WheelOfJeopardy.UI.Commands" xmlns:ui="clr-namespace:DeltaGroup.WheelOfJeopardy.UI.Converters" xmlns:U="clr-namespace:DeltaGroup.WheelOfJeopardy.UI.Controls" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" Background="{StaticResource ScreenBackgroundBrushKey}">
    <UserControl.CommandBindings>
        <CommandBinding Command="Commands:WoJCommands.Wager" CanExecute="CanExec" Executed="Wager"/>
        <CommandBinding Command="Commands:WoJCommands.StayInTurn" CanExecute="CanExec" Executed="ExecuteUseFreeTurn"/>
        <CommandBinding Command="Commands:WoJCommands.ForfeitTurn" CanExecute="CanExec" Executed="ExecuteForfeitTurn"/>
    </UserControl.CommandBindings>
    <UserControl.Resources>
        <ui:SelectedVisibilityConverter x:Key="SelectedVisibilityConverter" />
    </UserControl.Resources>
    <Canvas Width="1024" Height="768">
        <Canvas Width="1024" Height="768" Panel.ZIndex="1">
            <StackPanel >
                <Grid Height="80" Width="1024">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="2*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Button Grid.Column="0" Command="Commands:WoJCommands.Menu" Content="Quit"></Button>
                    <TextBlock Grid.Column="1" Text="{Binding Path=Name, BindsDirectlyToSource=True}" Style="{StaticResource ResourceKey=RoundTitle}"/>
                    <StackPanel Orientation="Horizontal" Grid.Column="2">
                        <TextBlock Text="Spins Left: " Style="{StaticResource ResourceKey=RoundTitle}" VerticalAlignment="Center"/>
                        <U:AdjustableSpinRemaining DataContext="{Binding BindsDirectlyToSource=True}" VerticalAlignment="Center"/>
                    </StackPanel>
                    
                </Grid>

                <ItemsControl Name="ContestantPanel" ItemsSource="{Binding Path=Contestants, BindsDirectlyToSource=True}" Background="{StaticResource StatusBarBackgroupBrushKey}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Margin="20,20">
                                <Canvas Canvas.Left="0" Canvas.Top="0"  Visibility="{Binding Path=IsPlaying, Converter={StaticResource SelectedVisibilityConverter}, BindsDirectlyToSource=True}">
                                    <Path  Width="49.4867" Height="36.0052" Stretch="Fill" Fill="Yellow" Data="F1 M 85.3218,707.328L 84.5658,708.088L 65.4685,708.088C 64.7618,708.088 64.1872,708.66 64.1872,709.368C 64.1872,710.077 64.7618,710.649 65.4685,710.649L 74.7031,710.649L 74.7031,713.376L 73.7778,714.238C 73.5365,713.996 73.2125,713.861 72.8725,713.861L 66.7512,713.861C 66.0445,713.861 65.4685,714.436 65.4685,715.142C 65.4685,715.85 66.0445,716.428 66.7512,716.428L 71.5898,716.428L 71.5898,719.26L 71.0311,719.82C 70.8338,719.7 70.6045,719.633 70.3645,719.633L 63.1858,719.633C 62.4778,719.633 61.9045,720.206 61.9045,720.913C 61.9045,721.622 62.4778,722.196 63.1858,722.196L 68.0045,722.196L 67.4072,723.112L 63.9031,724.356L 51.4591,724.356C 51.3245,724.24 51.1645,724.146 50.9872,724.093L 45.6485,722.496C 45.5018,722.272 45.2858,722.094 45.0232,721.998L 40.9645,720.5L 40.9645,704.08L 44.5805,704.08C 44.9205,704.08 45.2432,703.946 45.4858,703.704C 45.7272,703.464 45.8578,703.141 45.8578,702.8L 45.8578,702.121L 48.6618,702.121C 49.0032,702.121 49.3258,701.986 49.5672,701.746C 49.8098,701.505 49.9405,701.182 49.9405,700.841L 49.9405,700.002L 52.7392,700.002C 53.0805,700.002 53.4045,699.868 53.6458,699.621C 53.8872,699.381 54.0218,699.06 54.0218,698.721L 54.0218,697.877L 58.6178,697.877C 58.9578,697.877 59.2778,697.744 59.5232,697.502C 59.7645,697.26 59.8952,696.941 59.8952,696.597L 59.8952,695.758L 60.0845,695.758C 60.4258,695.758 60.7498,695.625 60.9911,695.377C 61.2325,695.135 61.3658,694.816 61.3658,694.476L 61.3658,693.472L 65.0071,693.472L 65.0071,697.601L 64.0018,697.601C 63.6605,697.601 63.3325,697.736 63.0952,697.976C 62.8538,698.214 62.7205,698.542 62.7205,698.882L 62.7205,701.025L 57.6378,701.025C 57.2965,701.025 56.9685,701.164 56.7325,701.402C 56.4898,701.644 56.3552,701.972 56.3552,702.307C 56.3552,702.652 56.4872,702.972 56.7325,703.213C 56.9711,703.456 57.2938,703.589 57.6378,703.589L 64.0018,703.589L 84.6845,703.589L 85.3218,704.225M 87.5125,702.792L 86.1231,701.402C 85.8831,701.164 85.5552,701.025 85.2178,701.025L 65.2818,701.025L 65.2818,700.161L 66.2871,700.165C 66.6272,700.165 66.9525,700.03 67.1938,699.789C 67.4338,699.544 67.5685,699.222 67.5685,698.882L 67.5685,692.189C 67.5685,691.85 67.4338,691.524 67.1938,691.285C 66.9525,691.042 66.6272,690.909 66.2871,690.909L 60.0845,690.909C 59.7458,690.909 59.4165,691.048 59.1791,691.285C 58.9378,691.521 58.8045,691.853 58.8045,692.189L 58.8045,693.19L 58.6178,693.194C 58.2778,693.194 57.9445,693.329 57.7085,693.572C 57.4711,693.809 57.3352,694.135 57.3352,694.476L 57.3352,695.314L 52.7392,695.314C 52.4045,695.314 52.0712,695.454 51.8338,695.69C 51.5965,695.928 51.4591,696.26 51.4591,696.597L 51.4591,697.438L 48.6618,697.438C 48.3218,697.438 47.9925,697.573 47.7525,697.814C 47.5152,698.053 47.3792,698.38 47.3792,698.721L 47.3792,699.56L 44.5805,699.56C 44.2392,699.56 43.9112,699.698 43.6712,699.936C 43.4325,700.172 43.2978,700.504 43.2978,700.841L 43.2978,701.517L 39.6832,701.517C 39.3445,701.517 39.0152,701.654 38.7765,701.892C 38.5365,702.13 38.4018,702.464 38.4018,702.8L 38.4018,721.393C 38.4018,721.93 38.7351,722.406 39.2392,722.594L 43.4751,724.158C 43.6338,724.433 43.8938,724.644 44.2125,724.741L 49.5485,726.336C 49.5965,726.41 49.6512,726.479 49.7138,726.542C 49.9512,726.781 50.2792,726.914 50.6205,726.914L 64.1245,726.914L 64.5511,726.845L 68.6712,725.388C 68.9378,725.293 69.1618,725.114 69.3178,724.877L 70.8431,722.534C 70.9965,722.596 71.1591,722.629 71.3218,722.629C 71.6511,722.629 71.9778,722.501 72.2285,722.25L 73.7778,720.702C 74.0178,720.457 74.1551,720.137 74.1551,719.794L 74.1551,716.836C 74.2071,716.842 74.2565,716.865 74.3085,716.865C 74.6378,716.865 74.9658,716.742 75.2165,716.49L 76.8885,714.814C 77.1285,714.574 77.2631,714.255 77.2631,713.91L 77.2631,710.649L 85.0951,710.649C 85.4365,710.649 85.7592,710.516 86.0018,710.274L 87.5125,708.762C 87.7525,708.522 87.8885,708.201 87.8885,707.858L 87.8885,703.696C 87.8885,703.356 87.7525,703.031 87.5125,702.792 Z "/>
                                </Canvas>
                                <StackPanel Margin="55,0,0,0">
                                    <TextBlock Text="{Binding Path=Name}" Style="{StaticResource ResourceKey=ContestantStatusInfo}"/>
                                    <Grid Margin="10,0,0,0">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="100"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition/>
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>

                                        <TextBlock Grid.Column="0" Grid.Row="0" Text="Free Spins:" Style="{StaticResource ResourceKey=ContestantStatusInfo}" />
                                        <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Path=FreeTurnCount}" Style="{StaticResource ResourceKey=ContestantStatusInfo}" />
                                        <TextBlock Grid.Column="0" Grid.Row="1" Text="Score:" Style="{StaticResource ResourceKey=ContestantStatusInfo}" />
                                        <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=Score}" Style="{StaticResource ResourceKey=ContestantStatusInfo}" />
                                    </Grid>
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <Screens:Board x:Name="JeopardyBoard" Grid.Column="0" Grid.RowSpan="2" CategorySelected="JeopardyBoard_CategorySelected" DebugMode="{Binding DebugMode}" Margin="0,20,0,0"/>

                    <StackPanel Grid.Column="1">
                        <Canvas>
                            <ContentControl Name="ContentArea">
                            </ContentControl>
                            <ContentControl Name="TransitionArea" Panel.ZIndex="100">
                            </ContentControl>
                        </Canvas>
                    </StackPanel>
                </Grid>
            </StackPanel>

        </Canvas>
        <Canvas Panel.ZIndex="100" Width="1024" Height="768">
            <Screens:NotificationMessage Canvas.Top="150" Canvas.Left="150" IsHitTestVisible="False"/>
        </Canvas>
    </Canvas>
</UserControl>
